package com.ttg.common.config;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class DynamicTableNameHelper {

    /**
     * 请求参数存取
     */
    private static final ThreadLocal<Map<String, String>> TABLE_SUFFIX = new ThreadLocal<>();


    public static void setTableSuffix(Map<String, String> tableSuffix) {
        TABLE_SUFFIX.set(tableSuffix);
    }

/*

    public static String getTableSuffixByKey(String key) {
        Map<String, String> tableSuffixMap = getTableSuffix();
        if (CollectionUtils.isNotEmpty(tableSuffixMap)) {
            if (StringUtils.isNotBlank(tableSuffixMap.get(key))) {
                return tableSuffixMap.get(key);
            }
        }
        return null;
    }
*/


    public static Map<String, String> getTableSuffix() {
        Map<String, String> tableSuffixMap = TABLE_SUFFIX.get();
        if (CollectionUtils.isNotEmpty(tableSuffixMap)) {
            return tableSuffixMap;
        }
        return new HashMap<>();
    }


}
